package com.jerry.reflect;

import com.sun.org.apache.xpath.internal.operations.Mod;
import org.hibernate.annotations.SourceType;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

/**
 * Created by Shirly on 2016/12/5.
 */
public class test6 {
    public static void main(String[] args) {
        try {
            Class a = Class.forName("com.jerry.reflect.Practice");
            Field[] fields = a.getDeclaredFields();
            Method[] methods = a.getDeclaredMethods();
            StringBuffer sb = new StringBuffer();
            sb.append(Modifier.toString(a.getModifiers())+" class "+a.getSimpleName()+"{\n");
            for(Field f : fields){
               sb.append(Modifier.toString(f.getModifiers()));
                sb.append(" "+f.getType().getSimpleName()+" "+f.getName()+";\n");
            }
            for (Method method : methods){
                System.out.println("方法的返回值类型："+method.getReturnType());
                System.out.println("方法的参数为："+method.getParameterTypes());
                System.out.println(Modifier.toString(method.getModifiers()));
            }
            sb.append("}");
//            System.out.println(sb.toString());\


        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
